﻿using System.Collections.Generic;
using UcAsp.Net.IDAL;
using UcAsp.Net.Model;

namespace UcAsp.Net.BLL
{
    public class SysParamBLL
    {
        private static readonly ISysParamDAL dal = DALFactory.DataAccess.CreateSysParam();

        public SysParam Insert(SysParam model)
        {
            return dal.Insert(model);
        }

        public bool Update(SysParam model)
        {
            return dal.Update(model);
        }

        public bool Delete(int id)
        {
            return dal.Delete(GetParamById(id));
        }

        public List<SysParam> GetListByGroupID(int id)
        {
            return dal.GetListByGroupID(id);
        }

        public SysParam GetParamById(int id)
        {
            return dal.GetParamByID(id);
        }

        public static string GetParamByName(string name)
        {
            SysParam param = dal.GetParamByName(name);
            if (param != null)
            {
                return param.ParamValue;
            }
            else
            {
                return string.Empty;
            }
            
        }

        public List<SysParam> Select(int pagesize, int pageindex, out int pagecount)
        {
            pageindex = pageindex - 1;
            return dal.Select(pagesize, pageindex, out pagecount);
        }
    }
}